package com.pasabahceambalaj.entity;

// Generated Oct 8, 2013 12:01:41 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.validator.NotNull;

/**
 * Isemirhareket generated by hbm2java
 */
@Entity
@Table(name = "isemirhareket", catalog = "ambalaj")
public class Isemirhareket implements java.io.Serializable {

	private Long id;
	private int version;
	private Isemirmalzeme isemirmalzeme;
	private Isemirurun isemirurun;
	private Hareketturgrup hareketturgrup;
	private Isemir isemirByVirmanisemirid;
	private Isemir isemirByIsemirid;
	private Sevk sevk;
	private Harekettur harekettur;
	private int miktar;

	public Isemirhareket() {
	}

	public Isemirhareket(Hareketturgrup hareketturgrup, Isemir isemirByIsemirid, Sevk sevk, Harekettur harekettur, int miktar) {
		this.hareketturgrup = hareketturgrup;
		this.isemirByIsemirid = isemirByIsemirid;
		this.sevk = sevk;
		this.harekettur = harekettur;
		this.miktar = miktar;
	}

	public Isemirhareket(Isemirmalzeme isemirmalzeme, Isemirurun isemirurun, Hareketturgrup hareketturgrup, Isemir isemirByVirmanisemirid, Isemir isemirByIsemirid, Sevk sevk, Harekettur harekettur, int miktar) {
		this.isemirmalzeme = isemirmalzeme;
		this.isemirurun = isemirurun;
		this.hareketturgrup = hareketturgrup;
		this.isemirByVirmanisemirid = isemirByVirmanisemirid;
		this.isemirByIsemirid = isemirByIsemirid;
		this.sevk = sevk;
		this.harekettur = harekettur;
		this.miktar = miktar;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Version
	@Column(name = "version", nullable = false)
	public int getVersion() {
		return this.version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "isemirmalzemeid")
	public Isemirmalzeme getIsemirmalzeme() {
		return this.isemirmalzeme;
	}

	public void setIsemirmalzeme(Isemirmalzeme isemirmalzeme) {
		this.isemirmalzeme = isemirmalzeme;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "isemirurunid")
	public Isemirurun getIsemirurun() {
		return this.isemirurun;
	}

	public void setIsemirurun(Isemirurun isemirurun) {
		this.isemirurun = isemirurun;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "phareketturgrupid", nullable = false)
	@NotNull
	public Hareketturgrup getHareketturgrup() {
		if (this.getHarekettur() != null) {
			return this.getHarekettur().getHareketturgrup();
		} else {
			return this.hareketturgrup;
		}
	}

	public void setHareketturgrup(Hareketturgrup hareketturgrup) {
		this.hareketturgrup = hareketturgrup;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "virmanisemirid")
	public Isemir getIsemirByVirmanisemirid() {
		return this.isemirByVirmanisemirid;
	}

	public void setIsemirByVirmanisemirid(Isemir isemirByVirmanisemirid) {
		this.isemirByVirmanisemirid = isemirByVirmanisemirid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "isemirid", nullable = false)
	@NotNull
	public Isemir getIsemirByIsemirid() {
		return this.isemirByIsemirid;
	}

	public void setIsemirByIsemirid(Isemir isemirByIsemirid) {
		this.isemirByIsemirid = isemirByIsemirid;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "sevkid", nullable = false)
	@NotNull
	public Sevk getSevk() {
		return this.sevk;
	}

	public void setSevk(Sevk sevk) {
		this.sevk = sevk;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "hareketturid", nullable = false)
	@NotNull
	public Harekettur getHarekettur() {
		return this.harekettur;
	}

	public void setHarekettur(Harekettur harekettur) {
		this.harekettur = harekettur;
		if(harekettur!=null){
			setHareketturgrup(harekettur.getHareketturgrup());
		}
	}

	@Column(name = "miktar", nullable = false)
	public int getMiktar() {
		return this.miktar;
	}

	public void setMiktar(int miktar) {
		this.miktar = miktar;
	}

}
